<?php
session_start ();
// 判断用户是否已经登录
if (! isset ( $_SESSION ["userinfo"] ) and empty ( $_SESSION ["userinfo"] ["userid"] )) {
	header ( "location:../index.php" );
	session_unset ();
	session_destroy ();
	exit ();
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Language" content="zh-CN">
<link href="./Resource/Style/base.yy.css" rel="stylesheet"
	type="text/css">
<link href="./Resource/Style/info.yy.css" rel="stylesheet"
	type="text/css">
</head>
<body>
<?php
require_once '../tools/SqlHelper.class.php';
if (isset ( $_POST ['user_submit'] ) and $_POST ['user_submit'] == '保存') {
	// 获取浏览器发过来的页面数据
	$editMsg = $_POST ['editMsg'];
	$user_id = $_SESSION ["userinfo"] ["userid"];
	// $user_id = "xufeng520";
	$sql = "UPDATE `detail_data_tb` SET `dd_soliloquy`='$editMsg' WHERE `user_id`='$user_id'";
	// 创建一个SqlHelper对象
	$sqlHelper = new SqlHelper ();
	$res = $sqlHelper->execute_dql ( $sql );
	if (! $res) {
		echo "<script>alert('保存内心独白失败')</script>";
	} else {
		echo "<script>alert('保存内心独白成功')</script>";
	}
	// 关闭连接
// 	mysql_free_result ( $res );
	$sqlHelper->close_connect ();
} else {
	$user_id = $_SESSION ["userinfo"] ["userid"];
	// $user_id = "xufeng520";
	$sql = "select dd_soliloquy from `detail_data_tb` where `user_id`='$user_id'";
	// 创建一个SqlHelper对象
	$sqlHelper = new SqlHelper ();
	$row = $sqlHelper->execute_dql ( $sql );
	$res = mysql_fetch_array ( $row );
	// 关闭连接
	$dd_soliloquy = $res ['dd_soliloquy'];
	if ($dd_soliloquy == "0") {
		$editMsg = "内容长度限定在120字内噢!";
	} else {
		$editMsg = $dd_soliloquy;
	}
	mysql_free_result ( $row );
	$sqlHelper->close_connect ();
}
?>
	<nav>
		<div class="info_nav">
			<ul>
				<li><a href="./baseData.php">基本资料</a></li>
				<li><a href="./Details.php">详细资料</a></li>
				<li><a class="a_out" href="#">内心独白</a></li>
				<li><a href="./uploadingPhoto.php">上传头像</a></li>
				<li><a href="./myPhoto.php">我的相册</a></li>
				<li><a href="./PersonalCondition.php">征友条件</a></li>
				<li><a href="./changePassword.php">修改密码</a></li>
			</ul>
		</div>
	</nav>
	<div class="info_con">
		<div class="heart">
			<form action="./soliloquy.php" method="post">
				<textarea maxlength="120" id="editMsg" name="editMsg"><?php echo $editMsg;?></textarea>
				<p>
					请不要在内心独白中有任何联系以及不良信息,谢谢！ <input
						style="background-color: #01CBD3; color: #fff; float: right; width: 180px; height: 40px; border: 0; font-size: 16px;"
						name="user_submit" type="submit" value="保存" />
				</p>
			</form>
		</div>
	</div>
	<!-- 	<script src="./Resource/Style/information.yy.js" type="text/javascript"></script> -->
</body>
</html>